#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
# @FileName  :users.py
# @Time      :2022/4/22 3:42 PM
# @Author    :Toliong toliong@foxmail.com
"""
from sqlalchemy.orm import Session

from schemas.users import UserCreate
from db.models.users import User
from core.hashing import Hasher


def create_new_user(user: UserCreate, db: Session):
    user = User(username=user.username,
        email = user.email,
        hashed_password=Hasher.get_password_hash(user.password),
        is_active=True,
        is_superuser=False
        )
    db.add(user)
    db.commit()
    db.refresh(user)
    return user

if __name__ == "__main__":
    pass
